package com.liusha.vinfoaddins.vinfoaddins.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.github.jdsjlzx.ItemDecoration.DividerDecoration;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.liusha.vinfoaddins.vinfoaddins.R;
import com.liusha.vinfoaddins.vinfoaddins.adapter.HomeAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 作者：杨祥
 * 日期：2017/5/11 - 10:17
 * 注释：首页
 */
public class MainHomeFragment extends Fragment {

    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.pull_rv)
    LRecyclerView mPullRv;
    Unbinder unbinder;

    private HomeAdapter mHomeAdapter;
    private LRecyclerViewAdapter mLRecyclerViewAdapter;
    private List<String> mStrings;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        unbinder = ButterKnife.bind(this, view);

        mStrings=new ArrayList<>();
        for(int i=0;i<10;i++){
            mStrings.add("");
        }

        mHomeAdapter=new HomeAdapter(getActivity(),mStrings);
        mLRecyclerViewAdapter=new LRecyclerViewAdapter(mHomeAdapter);

        DividerDecoration divider = new DividerDecoration.Builder(getActivity())
                .setColorResource(android.R.color.darker_gray)
                .build();
        mPullRv.addItemDecoration(divider);

        mPullRv.setLayoutManager(new LinearLayoutManager(getActivity()));
        mPullRv.setAdapter(mLRecyclerViewAdapter);

        mPullRv.setPullRefreshEnabled(false);
        mPullRv.setLoadMoreEnabled(false);
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
